<script>
	export default {
		onLaunch: function() {
			console.log('App Launch')
			// 检查是否已登录
			const hasLogin = uni.getStorageSync('hasLogin')
			const token = uni.getStorageSync('token')
			
			// 只有同时存在hasLogin标志和token才认为是已登录
			if (!hasLogin || !token) {
				// 清除可能存在的无效登录状态
				uni.removeStorageSync('hasLogin')
				uni.removeStorageSync('token')
				uni.removeStorageSync('refreshToken')
				uni.removeStorageSync('userInfo')
				
				// 未登录时跳转到登录页
				setTimeout(() => {
					// 使用原生方式跳转
					window.location.href = '#/pages/login/login';
				}, 100)
			} else {
				// 已登录，检查用户类型
				const userInfo = uni.getStorageSync('userInfo')
				console.log('当前用户类型:', userInfo ? userInfo.userType : '未知')
				
				// 已登录时跳转到首页
				setTimeout(() => {
					// 使用原生方式跳转
					window.location.href = '#/pages/index/index';
				}, 100)
			}
		},
		onShow: function() {
			console.log('App Show')
		},
		onHide: function() {
			console.log('App Hide')
		}
	}
</script>

<style>
	/*每个页面公共css */
	page {
		font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'SF Pro Display', 'Helvetica Neue', Helvetica, Segoe UI, Arial, Roboto, 'PingFang SC', 'miui', 'Hiragino Sans GB', 'Microsoft Yahei', sans-serif;
		background: linear-gradient(to bottom, #f0f8ff, #e6f2ff);
		color: #333333;
		font-size: 28rpx;
	}
	
	/* 按钮点击效果 */
	.btn:active {
		opacity: 0.8;
		transform: scale(0.98);
		transition: all 0.2s;
	}
	
	/* 清除按钮默认样式 */
	button {
		padding: 0;
		margin: 0;
		background-color: transparent;
	}
	
	button::after {
		border: none;
	}
	
	/* 通用卡片样式 */
	.card {
		background-color: rgba(255, 255, 255, 0.9);
		border-radius: 20rpx;
		padding: 30rpx;
		margin-bottom: 20rpx;
		box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.05);
		transition: all 0.3s;
	}
	
	.card:active {
		transform: scale(0.98);
	}
	
	/* 通用标题样式 */
	.section-title {
		font-size: 32rpx;
		font-weight: 600;
		margin-bottom: 24rpx;
		color: #2c3e50;
	}
	
	/* 通用输入框样式 */
	.input-box {
		background-color: rgba(255, 255, 255, 0.8);
		border-radius: 45rpx;
		padding: 20rpx 30rpx;
		font-size: 28rpx;
		box-shadow: inset 0 1rpx 3rpx rgba(0, 0, 0, 0.1);
		transition: all 0.3s;
	}
	
	.input-box:focus {
		background-color: #ffffff;
		box-shadow: inset 0 1rpx 3rpx rgba(0, 0, 0, 0.2);
	}
	
	/* iOS风格按钮 */
	.ios-btn {
		background: linear-gradient(to right, #007AFF, #5AC8FA);
		color: white;
		border-radius: 45rpx;
		padding: 20rpx 40rpx;
		font-weight: 500;
		text-align: center;
		box-shadow: 0 4rpx 10rpx rgba(0, 122, 255, 0.2);
		transition: all 0.3s;
	}
	
	.ios-btn:active {
		opacity: 0.85;
		transform: scale(0.98);
	}
	
	/* iOS风格分割线 */
	.divider {
		height: 1rpx;
		background-color: rgba(0, 0, 0, 0.1);
		margin: 20rpx 0;
	}
	
	/* iOS风格列表项 */
	.list-item {
		padding: 24rpx 30rpx;
		background-color: rgba(255, 255, 255, 0.8);
		border-radius: 16rpx;
		margin-bottom: 16rpx;
		display: flex;
		align-items: center;
		box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.03);
	}
</style>
